<?php
namespace app\index\controller;
use think\Db;
use think\facade\Env;
class Index extends Basic
{
    /**
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function index()
    {
        //获取配置文件
        $indexConfig= $this->getConfigs('index');
        //获取公司新闻
        // 通过配置设置要获取的cate_id
        $news   = Db::name('article')->field(['id', 'title' => 'name', 'abstract','create_time'])->where('group',1)->limit(4)->select();
        //获取公司案例
        $cases  = Db::name('article')->field(['id', 'banner','title' => 'name'])->limit(8)->select();
        //公司案例每页显示8条数据
        //模板赋值
        $this->assign([
            'page1'=>$indexConfig['page1']['value'],
            'page2'=>$indexConfig['page2']['value'],
            'page3'=>$indexConfig['page3']['value'],
            'page4'=>$indexConfig['page4']['value'],
            'page5'=>$indexConfig['page5']['value'],
            'page6'=>$indexConfig['page6']['value'],
            'cases'=>$cases,
            'news' =>$news
        ]);
        return $this->fetch();
    }

    public function about() {
        $aboutConfig = $this->getConfigs('about');
        //模板赋值
        $this->assign([
            'top'       => $aboutConfig['top']['value'],
            'mid'       => $aboutConfig['mid']['value'],
            'bottom'    => $aboutConfig['bottom']['value']
        ]);
        return $this->fetch();
    }

    public function contact() {
        return $this->fetch();
    }



}
